package jp.sinya;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

public class HttpDemoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("get...");
        String indexPath = this.getServletContext().getRealPath("/index.jsp");
        System.out.println(indexPath);
        //sUsers/koizumisinya/Desktop/WorkSpace/JavaSpace/MyJavaWebProject/out/artifacts/Demo1_war_exploded/index.jsp

        //也可以获取路径后，再创建输出流
        InputStream resource = this.getServletContext().getResourceAsStream("/index.jsp");

        //获取到WEB-INF文件夹下的所有东西
        Set<String> resourcePaths = this.getServletContext().getResourcePaths("/WEB-INF");
        System.out.println(resourcePaths);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("post...");
    }
}
